/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.pe.siass.test;

import com.pe.siass.beans.CasosBean;
import com.pe.siass.beans.ParametrosBean;
import com.pe.siass.dao.CasosDao;
import com.pe.siass.dao.ParametroDao;
import com.pe.siass.utils.USqlMapLoader;
import java.io.IOException;
import java.util.List;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;

/**
 *
 * @author Hrengifo
 */
public class Main2 {
 private Object ParametrosBean;
 private SqlSessionFactory sqlSessionFactory = null;

   public Main2() throws IOException {
        sqlSessionFactory =  USqlMapLoader.getInstance().getSession();
    }


   public void xxx(){
    try{
  
    SqlSession sqlSession = sqlSessionFactory.openSession();
    CasosDao casosDao = new CasosDao();

    CasosBean c = new CasosBean();
    c.setCasDescripcion("henry rengifo");
    c.setCasFecRegistro("12/12/2010");
    c.setCasNombre("yyyy");
    c.setCasReferencia("red");
    c.setCasUbigeo("12345");
    c.setCreadoPor("henry");
    c.setIpCreacion("123.12.3.122");
    c.setStReg("1");
    
    System.out.println(casosDao.insertCasos(c, sqlSession).getCasCodigo());
    
    c.setCasCodigo(4);
    c.setCasDescripcion("MASHA");
    c.setModificadoPor("henry");
    c.setIpModificacion("123.12.3.122");
     casosDao.updateCasos(c, sqlSession);


    c = new CasosBean();
    c.setCasDescripcion("MASHA");
    c.setStReg("1");
    List<CasosBean> x =  casosDao.selectCasos(c, sqlSession);

        for (CasosBean c2: x)
       {
             System.out.println(c2.getCasCodigo()+ " " + c2.getCasDescripcion());

       }

          sqlSession.commit();
     sqlSession.close();




    }catch(Exception e){
        e.printStackTrace();
    }
    }

   public static void main (String ar []){
       try{
            Main2 xx = new Main2();
            xx.xxx();
       }
        catch(Exception e){
        e.printStackTrace();
    }
   }

}
